<?php
namespace admin;

use controllers\BaseControllers;

class Admin extends BaseControllers{

    // 覆盖父类的构造方法
    public function __construct(){
        $loader = new \Twig\Loader\FilesystemLoader(TEMPDIR.'/app/views/admin');
        $this->twig = new \Twig\Environment($loader, [
            // 'cache' => '/path/to/compilation_cache',
        ]);
        $this->assign('session',$_SESSION);

        if(!ew_login('admin')){
            $this->error('/admin/login',"你还没有登录,请先登录");
        }
    }
    protected function display($template){

        $url = getCurUrl();
        $this->assign('url',$url.'/app/views/admin/resource');//自己模板下的css js images
        $this->assign('public',$url.'/app/views/public');//所有模板公共的前端css js images
        $this->assign('res',$url.'/uploads');//文件上传资源

        echo $this->twig->render($template.'.html',$this->data);
    }

}

